/**
 * @(#)Grill.java
 *
 *
 * @author 
 * @version 1.00 2012/3/30
 */


public class Morpion {
	
	private int Long,Haut,grille;
	
	private int x=0,y=0;
	
	private int [][] mat;
	
	private boolean isOdd,isExist;

    public Grille(int grille) 
    {
    	this.isOdd =true;
    	if(grille == 1)
    	{
    		PanelInit(14,14,grille);
    	}
    	if(grille == 2)
    	{
    		PanelInit(18,18,grille);
    	}
    	if(grille == 3)
    	{
    		PanelInit(22,22,grille);
    	}
    }
    //public void PanelInit(int Long,int Haut,int grille)
    {
    	this.Long=Long;
    	this.Haut=Haut;
    	this.grille=grille;
    	mat =new int[Long+1][Haut+1];
    	for(int i=0;i<=Long;i++)
    	{
    		for(int j=0;j<=Haut;j++)
    		{
    			mat[i][j]=-1;
    		}
    	}
    }
    
    //public boolean getisOdd()
    {
    	return this.isOdd;
    }
    
    //public void setisOdd(boolean isodd)
    {
    	if(isodd)
    		this.isOdd=true;
    	else
    		this.isOdd=false;	
    }
    
    //public boolean getisExist()
    {
    	return this.isExist;
    }
    
    public int getLong()
    {
    	return this.Long;
    }
    
    public int getHaut()
    {
    	return this.Haut;
    }
    
    //public int getGrille()
    {
    	return this.grille;
    }
    
    public int[][] getMat()
    {
    	return mat;
    }
    
    private boolean badxy(int x,int y)
    {
    	if(x >= Long+20 || x<0)
    		return true;
    	return y >= Haut+20 || y<0;
    }
    
    private boolean chessExist(int i,int j)
    {
    	if(this.mat[i][j]==1 || this.mat[i][j]==2)
    		return true;
    	return false;
    }
    
    public void readyplay(int x,int y)
    {
    	if(badxy(x,y))
    		return;
    	if(chessExist(x,y))
    		return;
    	this.mat[x][y]=3;
    }
    
    public void play(int x,int y)
    {
    	if(badxy(x,y))
    		return;
    	if(chessExist(x,y))
    	{
    		this.isExist=true;
    		return;
    	}
    	else
    	this.isExist=false;
    	if(getisOdd())
    	{
    		setisOdd
    	}
    }
       
    
    
}